<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Ord() - Syntax &amp; Usage | AutoHotkey</title>
<meta name="description" content="The Ord function returns the ordinal value (numeric character code) of the first character in the specified string." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>Ord() <span class="ver">[v1.1.21+]</span></h1>

<p>Returns the ordinal value (numeric character code) of the first character in the specified string.</p>

<pre class="Syntax">Number := <span class="func">Ord</span>(String)</pre>
<h2>Parameters</h2>
<dl>

  <dt>String</dt>
  <dd><p>The string whose ordinal value is retrieved.</p></dd>

</dl>

<h2>Return Value</h2>
<p>This function returns the ordinal value of <em>String</em>, or 0 if <em>String</em> is empty. If <em>String</em> begins with a Unicode supplementary character, this function returns the corresponding Unicode character code (a number between 0x10000 and 0x10FFFF). Otherwise it returns a value in the range 0 to 255 (for ANSI) or 0 to 0xFFFF (for Unicode). See <a href="../Compat.htm#Format">Unicode vs ANSI</a> for details.</p>

<h2>Remarks</h2>
<p>Apart from the Unicode supplementary character detection, this function is identical to <a href="Asc.htm">Asc()</a>.</p>

<h2>Related</h2>
<p><a href="Asc.htm">Asc()</a>, <a href="Chr.htm">Chr()</a></p>
<h2>Examples</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a>: Both message boxes below show 116, because only the first character is considered.</p>
<pre>MsgBox, % Ord("t") 
MsgBox, % Ord("test")</pre>
</div>

</body>
</html>
